package com.zt.rongda.workbill.controller;

import net.sf.json.JSONObject;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zt.rongda.workbill.service.WorkbillTaskService;
import com.zt.servlet.ReqBean;
import com.zt.servlet.RequestAttribute;
import com.zt.servlet.Response;

@Controller
@RequestMapping(value = "/workbill/task")
public class WorkbillTaskController {

    @Autowired
    private WorkbillTaskService workbillTaskService;

    @RequestMapping(value = "/query")
    @ResponseBody
    public JSONObject query(@RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        return Response.response(workbillTaskService.getTable(reqBean));
    }
    
    @RequestMapping(value = "/tasksOfWorkbill")
    @ResponseBody
    public JSONObject getWorkbillTasks(@RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        return Response.responseSuccess(workbillTaskService.getWorkbillTasks(reqBean.getInfo("workbillId")));
    }
    
    @RequestMapping(value = "/tasksOfOrderItem")
    @ResponseBody
    public JSONObject getOrderItemTasks(@RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        return Response.responseSuccess(workbillTaskService.getOrderItemTasks(reqBean.getInfo("orderItemId")));
    }
    
    @RequestMapping(value = "/complete")
    @ResponseBody
    public JSONObject completeTask(@RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        workbillTaskService.completeTask(reqBean);
        return Response.responseSuccess();
    }
    
    

}